import { post, get, put } from '@/utils/request';
import { LoginRequest, LoginResponse, UserInfo } from './types';

// 认证相关 API
export const authApi = {
  // 登录
  login: (data: LoginRequest): Promise<LoginResponse> =>
    post<LoginResponse>('/auth/login', data),

  // 注册
  register: (data: any) =>
    post('/auth/register', data),

  // 获取当前用户信息
  getMe: (): Promise<UserInfo> =>
    get<UserInfo>('/auth/me'),

  // 更新当前用户信息
  updateMe: (data: any) =>
    put('/auth/me', data),

  // 修改密码
  changePassword: (data: any) =>
    put('/auth/me/password', data),

  // 登出
  logout: (): Promise<void> =>
    post('/auth/logout'),

  // 刷新Token
  refreshToken: (): Promise<{ token: string }> =>
    post<{ token: string }>('/auth/refresh'),
}; 